<?php
require_once 'mail.class.php';
require_once 'jsonOut.func.php';
$mail = new cs_smtp('smtp.exmail.qq.com');
if ($mail->errstr){
	jsonOut(250, "无法连接smtp".$mail->errstr, array());
	die();
}

if (!$mail->login('lostnfound@hcdstudio.cn',"alsldl2LNF")){
	jsonOut(251, "无法连接smtp".$mail->errstr, array());
	die();
}

$sql = new mysqli("localhost", "lnf", "", "lostnfound");
if ($sql->connect_error) {
	jsonOut(3306, '数据库出错'.$sql->connect_error, array());
	die();
}

$email = $_POST["email"];
$res = $sql->query("select uid from user where paswrod is not null and email='$email'");
$row = $res->fetch_array();
if ($row) {
	jsonOut(201, "用户已注册", array());
	die();
}
//生成code 获取当前时间
$sql->query("update user set email_code='adsf' where email='$email'");
if($sql->affected_rows <= 0){
	$sql->query("insert into user (uname,nickname,email) values ('$email','$email','$email')");
}
// var_dump($res1);

// $mail->send("850476264@qq.com", "测试邮件", "<font color='red'>测试测试测试</font>测试");
jsonOut(200, "success已发送邮件", array());
